﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business;
using ZLCMS.Data.Model;
using NHibernate;
using ZLCMS.Business.DwzFrame;
using NHibernate.Criterion;
using ZLCMS.Business.Util;

namespace ZLCMS.Web.SystemManage.Basics.Param.Group
{
    public partial class Delete : System.Web.UI.Page
    {

        protected void Page_Load(object sender, EventArgs e)
        {
            ZLCMS.Business.DwzFrame.FrameHelper framePage = new ZLCMS.Business.DwzFrame.FrameHelper(this);
            string ids = Request["ids"];
            if (!string.IsNullOrEmpty(ids))
            {
                string[] idStrs = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                

                using (NHibernate.ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
                {
                    session.CreateSQLQuery("delete from sys_param where item_code in (:ids) or group_code in  (:ids)")
                        .SetParameterList("ids", idStrs.ToArray())
                        .ExecuteUpdate();

                    session.Flush();

                    ParamKit.GetInstance().Fresh();
                    framePage.Alert(new ZLCMS.Business.DwzFrame.ReturnCode() { statusCode = 200, message = "操作成功!", navTabId = framePage.NavTabId });
                }
            }
            else
            {
                framePage.Alert(new ZLCMS.Business.DwzFrame.ReturnCode() { statusCode = 300, message = "参数错误" });
            }

        }

    }
}
